package com.qhhc.hospital.controller;

import com.qhhc.hospital.entity.PatientUser;
import com.qhhc.hospital.service.IPatientUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class PatientUserController {
    @Autowired
    IPatientUserService patientUserService;

    @RequestMapping("/insertPatientUser")
    public String insertPatientUser(@RequestBody PatientUser patientUser){
        patientUserService.insert(patientUser);
        return "success";
    }

    @RequestMapping("/getAllPatientUsers")
    public List<PatientUser> getAllPatientUsers(){
        List<PatientUser> patientUsers = patientUserService.selectAll();
        return patientUsers;
    }

    @RequestMapping("/getPatientUser/{pId}")
    public PatientUser getPatientUserById(@PathVariable("pId") Integer pId){
        return patientUserService.selectById(pId);
    }

    @RequestMapping("/updatePatientUser")
    public String updatePatientUser(@RequestBody PatientUser patientUser){
        patientUserService.update(patientUser);
        return "success";
    }

    @RequestMapping("/deletePatientUser/{pId}")
    public String deletePatientUser(@PathVariable("pId") Integer pId){
        patientUserService.delete(pId);
        return "success";
    }
} 